package com.zhuozhengsoft.pageoffice6springboot2back.controller;

import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
import com.zhuozhengsoft.pageoffice.wordwriter.WordDocument;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping(value = "/ReadOnly")
public class ReadOnlyController {

    @RequestMapping(value = "/Word")
    public String showWord(HttpServletRequest request) {
        WordDocument wordDoc = new WordDocument();
        wordDoc.setDisableWindowSelection(true);//禁止选中
        wordDoc.setDisableWindowRightClick(true);//禁止右键

        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.setWriter(wordDoc);//此句必须
        poCtrl.setAllowCopy(false);//禁止拷贝，同时就实现了禁止F12另存功能了。
        poCtrl.webOpen("/doc/ReadOnly/test.docx", OpenModeType.docReadOnly, "张三");
        return poCtrl.getHtml();
    }
}
